package br.inf.solutions.apresentacoes.ssp.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import br.com.vexillum.model.CommonEntityActivated;
import br.com.vexillum.model.annotations.SearchField;
import br.com.vexillum.model.annotations.Validate;
import br.com.vexillum.model.annotations.ValidatorClass;
import br.inf.solutions.apresentacoes.ssp.model.enums.TypeOfCaution;
import br.inf.solutions.apresentacoes.ssp.model.interfaces.IExistsPerson;

@SuppressWarnings("serial")
@ValidatorClass(validatorClass = "br.inf.solutions.apresentacoes.ssp.control.validator.StealthWeaponValidator")
@Entity
@Table(name = "stealth_weapon")
public class StealthWeapon extends CommonEntityActivated implements IExistsPerson {

	public StealthWeapon() {
		this.itensStealthWeapon = new ArrayList<>();
		this.weapons = new ArrayList<>();	
		this.person = new Person();
	}
	
	@Validate(notNull = true)
	@SearchField(introspect = true)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "person_id", nullable = false, updatable = true, unique = false)
	private Person person;

	@Validate(notNull = true)
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "type_caution", unique = false, updatable = true)
	private TypeOfCaution typeCaution;

	@Validate(notNull = true)
	@Column(name = "startDate", nullable = false, unique = false, updatable = true)
	private Date startDate;

	@Column(name = "returnDate", unique = false, updatable = true)
	private Date returnDate;

	@Column(name = "observation", unique = false, updatable = true)
	private String observation;

	@Validate(notNull = false)
	@Column(name = "open", nullable = true, unique = false, updatable = true)
	private Boolean open;
		
	@Cascade(CascadeType.ALL)
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "stealthWeapon", targetEntity = ItensStealthWeapon.class)
	private List<ItensStealthWeapon> itensStealthWeapon;
	
	@Transient
	private List<Weapon> weapons;

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public TypeOfCaution getTypeCaution() {
		return typeCaution;
	}

	public void setTypeCaution(TypeOfCaution typeCaution) {
		this.typeCaution = typeCaution;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getReturnDate() {
		return returnDate;
	}

	public void setReturnDate(Date returnDate) {
		this.returnDate = returnDate;
	}

	public String getObservation() {
		return observation;
	}

	public void setObservation(String observation) {
		this.observation = observation;
	}

	public Boolean getOpen() {
		return open;
	}

	public void setOpen(Boolean open) {
		this.open = open;
	}
	
	public List<ItensStealthWeapon> getItensStealthWeapon() {
		return itensStealthWeapon;
	}

	public void setItensStealthWeapon(List<ItensStealthWeapon> itensStealthWeapon) {
		this.itensStealthWeapon = itensStealthWeapon;
	}

	public List<Weapon> getWeapons() {
		return weapons;
	}

	public void setWeapons(List<Weapon> weapons) {
		this.weapons = weapons;
	}
}